const path = require("path");
const webpack = require("webpack");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const outDir=path.resolve(__dirname,'dist/dll');

module.exports = {
  entry: {
    react: [
      "react",
      "react-dom",
      "react-router-dom",
      "redux",
      "react-redux",
    ],
  },
  mode: process.env.NODE_ENV==="development"?"development":"production",
  output: {
    path: outDir,
    filename: "[name].dll.js",
    library: "[name]_lib",
  },
  plugins: [
    new CleanWebpackPlugin(),
    new webpack.DllPlugin({ // 会生成一个json文件，里面是关于dll.js的一些配置信息
      path: path.join(
        outDir,
        "[name]_manifest.json"
      ),
      name:"[name]_lib",// 与上面output中配置对应
    }),
  ],
  performance: {
    maxAssetSize: 1*1024*1024,//默认值：250000 (bytes)
    maxEntrypointSize: 1*1024*1024
  }
};